package com.smarth.zhizulian.utils.listhelper.impl.adapter;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.smarth.zhizulian.utils.listhelper.inter.IDataAdapter;

import java.util.List;

/**
 * Created by 18865 on 2018/2/8.
 */

public abstract class RMultiListDataAdapter<T extends MultiItemEntity> extends BaseMultiItemQuickAdapter<T, BaseViewHolder> implements IDataAdapter<List<T>> {

    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public RMultiListDataAdapter(List<T> data) {
        super(data);
    }

    @Override
    public void onGetData(List<T> ts, boolean isRefresh) {
        if (isRefresh) {
            setNewData(ts);
        } else {
            addData(ts);
        }
    }

    @Override
    public boolean isDataEmpty() {
        return getData() != null && getData().isEmpty();
    }

    @Override
    public List<T> getMyData() {
        return getData();
    }
}
